import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';

import 'package:cc_sdk/cc_widgets.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  CommentController controller;

  @override
  void initState() {
    super.initState();
    controller = new CommentController(
        onLikeClick: onLikeClick,
        onShareClick: onShareClick,
        onStatisticsEvent: onStatisticsEvent,
        onLogin: onLogin,
        getMemberInfo: getMemberInfo);
  }

  onLikeClick() {
    print("onLikeClick..................>>>>>>>>>>>>>>>>>>>>>>>>>");
  }

  onShareClick() {
    print("onShareClick..................>>>>>>>>>>>>>>>>>>>>>>>>>");
  }

  onStatisticsEvent(statistics) {}

  onLogin() {
    print("登录............>>>>>>>>>>>>>>>>>>>>>>>>>");
  }

  Future<MemberInfo> getMemberInfo(int memberId) {
    return Future.value(MemberInfo(memberId, "测试用户",
        "http://res.test.hsq168.co/upload/MX/2019/6/30/16/d5f9571c-b742-433a-afd1-69d5787a08a4.webp"));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Container(
          child: Column(
            children: <Widget>[
              Image.network(
                "http://res.test.hsq168.co/upload//PayCenterDemo/products/1.jpg?format=webp",
                width: 200,
                height: 100,
              ),
              Expanded(
                child: CommentWidget(
                  parentId: 0,
                  outId: "test001",
                  memberId: 0,
                  controller: controller,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
